import { Component, OnInit } from '@angular/core';
import { ApiService } from '../../../../providers/ApiPro.service';
import { parts } from '../HuoMesstmp.model';

@Component({
  selector: 'app-MesshuoyunAdmin',
  templateUrl: './MesshuoyunAdmin.component.html',
  styleUrls: ['./MesshuoyunAdmin.component.scss']
})
export class MesshuoyunAdminComponent implements OnInit {
  public pageIndex = 1;
  public data = [];
  public _total = 0;
  public parts: parts = new parts();
  constructor(
    public apiService: ApiService
  ) { }

  ngOnInit() {
    this.loadAll();
  }


  loadAll(){
    let url = "findlogisticscompanys";
    if(!this.parts.logisticsCompanyName){
      delete this.parts.logisticsCompanyName;
    }
    if(!this.parts.contacts){
      delete this.parts.contacts;    
    }
    if(!this.parts.contactsMobile){
      delete this.parts.contactsMobile;
    }
    this.apiService.get(url,this.parts)
      .then(res =>{
        this._total = res.totalCount;
        this.data = res.result;
        console.log(res);
      })
  }


  resetIndex(e) {
        this.parts.setPage(e);
        this.loadAll();
  }
}
